package com.jinsi.controller;

import com.jinsi.pojo.ScUser;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


@Controller
public class ViewController {

    //登录页面
    @RequestMapping("/login")
    public String login(){
        return "/login";
    }

    /**
     * 登录是否有数据
     */
    @RequestMapping("/")
    public String login(HttpServletRequest request) {
        HttpSession session = request.getSession();
        ScUser user = (ScUser) session.getAttribute("user");
        if (user != null) {
            return  "redirect:/index/index.html";
        }else {
            return "/login";
        }

    }

    //注册页面
    @RequestMapping("/register")
    public String register(){
        return "/register";
    }

}
